package cn.tedu.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ConsumerController {
    @Autowired
    private ConsumerApi consumerApi;

    @RequestMapping("/hello")
    @SentinelResource("doFindById")//热点限流
    public String doFindById(@RequestParam("id") Integer id){
        return "hello"+ id;
    }

    @RequestMapping("/menus")
    public String getMenuList(){ //返回值应该按服务提供者的返回值进行接收或者设置
        String menus = consumerApi.getMenus();
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return menus;
    }
}

